<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>活体检测管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
    <script type="text/javascript">
        var grid = null;
        var callback = function () {
            grid.reload();
        };
        var addGSData_s = {};
        $(function () {
            $("#searchBar").ligerForm();
            $("#ligergrid1").ligerGrid({
                url: '<%=path%>/custpay/cmmlivechk/initList.do',
                method : 'get',
                parms:getSearchParams(),
                columns: [
                    { display: '业务类型', name: 'busTypeNm', width: 100, align: 'center', enabledSort:true},
                    { display: '合同号', name: 'lsCntNo', width: 150, align: 'center', enabledSort:true},
                    { display: '来源', name: 'contractSourceNm', width: 150, align: 'center', enabledSort:true},
                    { display: '平台', name: 'contractPlatformNm', width: 80, align: 'center', enabledSort:true},
                    { display: '渠道', name: 'contractChannelNm', width: 150, align: 'center', enabledSort:true},
                    { display: '客户姓名', name: 'cstNm', width: 100, align: 'center', enabledSort:true},
                    { display: '身份证号', name: 'certNo', width: 150, align: 'center', enabledSort:true},
                    { display: '手机号', name: 'mp', width: 150, align: 'center', enabledSort:true},
                    { display: '级别', name: 'liveLevelNm', width: 80, align: 'center', enabledSort:true},
                    { display: '评分', name: 'liveScore', width: 80, align: 'center', enabledSort:true},
                    {
                        display: '身份证照片', name: 'identiFileList', width: 300, align: 'center', enabledSort:true,
                        render: function (rowdata, rowindex, value){
                            if(rowdata && rowdata.identiFileList && rowdata.identiFileList.length > 0){
                                var h = "";
                                for(var i = 0;i < rowdata.identiFileList.length; i++) {
                                    var fileNm = rowdata.identiFileList[i].fileNm;
                                    var filePath = rowdata.identiFileList[i].filePath;
                                    h+='<a href="javascript:openFile(\''+filePath+'\',\'身份证照片\')">'+fileNm+'</a>'+ ";";
                                }
                                if(h != ""){
                                    h = h.substring(0,h.length - 1);
                                }
                                return h;
                            }
                        }
                    },
                    {
                        display: '照片', name: 'livefileList', width: 300, align: 'center', enabledSort:true,
                        render: function (rowdata, rowindex, value){
                            if(rowdata && rowdata.livefileList && rowdata.livefileList.length > 0){
                                var h = "";
                                for(var i = 0;i < rowdata.livefileList.length; i++) {
                                    var fileNm = rowdata.livefileList[i].fileNm;
                                    var filePath = rowdata.livefileList[i].filePath;
                                    h+='<a href="javascript:openFile(\''+filePath+'\',\'照片\')">'+fileNm+'</a>'+ ";";
                                }
                                if(h != ""){
                                    h = h.substring(0,h.length - 1);
                                }
                                return h;
                            }
                        }
                    },
                    { display: '状态', name: 'auditStatusNm', width: 100, align: 'center', enabledSort:true},
                    { display: '备注', name: 'liveRemark', width: 150, align: 'center', enabledSort:true},
                    { display: '操作时间', name: 'crtTm', width: 150, align: 'center', enabledSort:true,render: renderDate},
                    {
                        display: '操作',width: 100,align: 'left',
                        render: function (rowdata, rowindex, value){
                            var h3 = '';
                            h3 += '<a class="sq-button-hasicon" href="javascript:addWhiteList('+rowdata.bnrId+')"><i class="sqBtnIco_26"></i>添加白名单</a>';
                            return h3;
                        }
                    }
                ],
                pageSize: 10,
                root: 'rows',
                record: 'total',
                hideLoadButton: true,
                width: '100%',
                height: '100%',
                heightDiff: -2,
                checkbox: false,
                rownumbers: true,
                allowUnSelectRow: true,
                alternatingRow: false,
                onBeforeShowData: function () {
                    var grid = this;
                    grid.collapsedRows = [];
                }
            });
            grid = liger.get("ligergrid1");

            $("#searchBtn").click(function(event) {
                var form = new liger.get("searchBar");
                var data = form.getData();
                console.log(data);
                for (name in data){
                    grid.setParm(name,data[name]);
                };
                grid.reload();
            });
            $("#clearBtn").click(function(event) {
                clearLigerForm("searchBar");
            });
            $("#dateform").ligerForm();

            //编辑保存
            $("#saveChange_Btn").click(function (event) {

                var form = liger.get("change_form");

                if (!form.valid()) {
                    $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                    return false; //验证不通过，不执行以下代码
                }

                var data = form.getData();
                $.ligerDialog.hide();
                //以下应该有一段Ajax交互
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: data,
                    url: '<%=path%>/custpay/cmmBindingCart/modify.do?id=' + addGSData_s.id+"&cstId="+addGSData_s.cstId,
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            bankHeadQ = null;
                            $("#resetBtn").click();
                            $("#searchBtn").click();
                        } else {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }
                    }
                });
            });
        });
        function openFile(url){
            $.ligerDialog.open({
                width: 500,
                height:500,
                //top: 100,
                title: '照片',
                target: "<img src='"+url+"' />"
            });
        }

        //查询参数
        function getSearchParams(){
            var form = new liger.get("searchBar");
            var data = form.getData();
            return data;
        }

        function addWhiteList(id){
            var tit = '白名单管理';
            var tabid='addWhiteList';
            Add_navTab(tabid, tit, '<%=path%>/custpay/cmmwhitelist/toListPage.do', callback);
        }

        //修改事件
        function change(_id) {
            $.ajax({
                type: 'get',
                dataType: 'json',
                url: '<%=path%>/custpay/cmmBindingCart/getById.do?id=' + _id,
                success: function (msg) {
                    if (msg.success == 1) {
                        //$.ligerDialog.success(msg.info)
                        openChange();//弹出修改框
                        setData(msg.data);//设置数据
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        }
        function openChange() {
            $.ligerDialog.open({
                width: 450,
//            top: 100,
                title: '修改客户开户银行信息',
                target: $("#change_Html"),
                onHideDialog: function () {
                    clearLigerForm("change_form");
                }
            });
            var ligerForm = $("#change_form").ligerForm({validate: true});
        }
        //设置页面数据
        function setData(data) {
            var form = liger.get("change_form");
            addGSData_s.id = data.id;
            addGSData_s.cstId = data.cstId;
            form.setData({
                accNm: data.accNm,
                cardTel: data.cardTel,
                certNo: data.certNo
            });
        }

        //删除
        function del(_id,_cstId) {
            if (!_id)return;
            $.ligerDialog.confirm('确定删除吗?', function (flag) {
                if (flag == false)return;
                var wait_dialog;
                $.ajax({
                    type: 'get',
                    dataType: 'json',
                    url: '<%=path%>/custpay/cmmBindingCart/removeById.do?id=' + _id+"&cstId="+_cstId,
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            grid.reload($('.pcontrol input', grid.toolbar).val());
                        } else {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }
                    }
                });
            });
        }
        function autoCharge(_id,_cstId,_isAuto){
            if (!_id)return;
            $.ligerDialog.confirm('确定该操作吗?', function (flag) {
                if (flag == false)return;
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    url: '<%=path%>/custpay/cmmBindingCart/autoChargeOperate.do',
                    data:{"id":_id,"cstId":_cstId,"isAuto":_isAuto},
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            grid.reload($('.pcontrol input', grid.toolbar).val());
                        } else {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }
                    }
                });
            });
        }
        //格式化时间
        function renderDate(rowdata, index, value) {
            var dateStr = "";
            if (null != value) {
                var date = new Date(value);
                dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
            }
            return dateStr;
        }



    </script>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">客户姓名</div>
                    <div class="field">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">身份证号</div>
                    <div class="field">
                        <input name="certNo" id="certNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">级别</div>
                    <div class="field">
                        <select name="liveLevelCd" id="liveLevelCd" data-value=" " validate="{required:true,select:true}">
                            <option value=" " seleted>请选择</option>
                            <c:forEach items="${liveLevelCdList }" var="kv">
                                <option value="${kv.key }">${kv.value }</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>

                <div class="clearFix"></div>
                <div class="btnsBox formBtns notRight">
                    <span id="searchBtn" class="sq-button-round"><i class="sqBtnIco_1"></i>查询</span>
                    <span id="clearBtn" class="sq-button-round"><i class="sqBtnIco_19"></i>清空</span>
                </div>

            </div>
        </form>
    </div>
</div>
<div id="ligergrid1" class="sq-grid"></div>

<div id="open_Html" style="display:none">
    <img src="/i/eg_tulip.jpg"  alt="上海鲜花港 - 郁金香" />
</div>
</body>
</html>
